namespace ScrumSprintMonitor.Implementation
{
	#region #using Directives

	using System;
	using System.Collections.Generic;
	using System.ComponentModel;

	using Infrastructure;

	#endregion

	public class WorkItemCopy : IWorkItemAdapter
	{
		private readonly string assignedTo;
		private readonly string changedBy;
		private readonly DateTime changedDate;
		private readonly double doneWork;
		private readonly int id;
		private readonly double remainingWork;
		private readonly WorkItemState state;
		private readonly string team;
		private readonly string title;
		private readonly WorkItemType type;

		#region Implementation of IWorkItemAdapter

		public void Initialize()
		{
			throw new NotImplementedException();
		}

		public void UpdateFrom(IWorkItemAdapter sourceAdapter)
		{
			throw new NotImplementedException();
		}

		public int Id
		{
			get { return this.id; }
		}

		public WorkItemType Type
		{
			get { return this.type; }
		}

		public WorkItemState State
		{
			get { return this.state; }
			set { throw new NotSupportedException(); }
		}

		public string Title
		{
			get { return this.title; }
			set { throw new NotSupportedException(); }
		}

		public double RemainingWork
		{
			get { return this.remainingWork; }
			set { throw new NotSupportedException(); }
		}

		public double DoneWork
		{
			get { return this.doneWork; }
			set { throw new NotSupportedException(); }
		}

		public string Team
		{
			get { return this.team; }
			set { throw new NotSupportedException(); }
		}

		public string AssignedTo
		{
			get { return this.assignedTo; }
			set { throw new NotSupportedException(); }
		}

		public string ChangedBy
		{
			get { return this.changedBy; }
			set { throw new NotSupportedException(); }
		}

		public DateTime ChangedDate
		{
			get { return this.changedDate; }
			set { throw new NotSupportedException(); }
		}

		#endregion

		public WorkItemCopy(IWorkItemAdapter src)
		{
			this.id = src.Id;
			this.type = src.Type;
			this.state = src.State;
			this.title = src.Title;
			this.team = src.Team;
			this.remainingWork = src.RemainingWork;
			this.doneWork = src.DoneWork;
			this.assignedTo = src.AssignedTo;
			this.changedBy = src.ChangedBy;
			this.changedDate = src.ChangedDate;
		}

		#region IWorkItemAdapter Members

#pragma warning disable 0067
		/// <summary>
		///   Occurs when a property value changes.
		/// </summary>
		public event PropertyChangedEventHandler PropertyChanged;
#pragma warning restore 0067

		#endregion

		public static BindingList<IWorkItemAdapter> ConvertToBindingList(IList<IWorkItemAdapter> list)
		{
			var workItems = new BindingList<IWorkItemAdapter>();

			foreach (var workItem in list)
			{
				workItems.Add(new WorkItemCopy(workItem));
			}

			return workItems;
		}
	}
}